<?php

namespace backend\models\form;

use yii\base\Model;
use backend\service\RbacService ;
use Yii;

/**
 *  角色权限表单
 */
class RolePermissionForm extends Model {
    
    public $name;
    public $permission;

    /**
     * @inheritdoc
     */
    public function rules() {
        return [
            [['name', 'permission'], 'required'],
        ];
    }

    public function attributeLabels() {
        return [
            'name' => '名称',
            'permission' => '权限',
        ];
    }
    
    public function getNewPermissions($role_name){
        $new_premission = RbacService::findNewPermissions($role_name) ;
        return $new_premission ;
    }
    
    public function addRolePermission(){
        $add_rs = RbacService::addRolePermissions($this->name, $this->permission) ;
        return $add_rs ;
    }
    
}
